package com.woniu.sharepark.propertysystem.service.impl;

import com.woniu.sharepark.propertysystem.dao.CommunityDAO;
import com.woniu.sharepark.propertysystem.dao.OrderDAO;
import com.woniu.sharepark.propertysystem.dto.CommunityDTO;
import com.woniu.sharepark.propertysystem.dto.OrderDTO;
import com.woniu.sharepark.propertysystem.service.CommunityService;
import com.woniu.sharepark.propertysystem.pojo.Community;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 小区实现类
 * @author xin
 * @date 2019/6/1 16:45
 * version v1.0
 */
@Service
public class CommunityServiceImpl implements CommunityService {

    @Resource
    private CommunityDAO communityDAO;

    @Resource
    private OrderDAO orderDAO;

    @Override
    public List<Community> findAllCommunity(Integer currentPage, Integer pageSize) {
        return communityDAO.selectAllCommunity(currentPage,pageSize);
    }

    @Override
    public List<Community> searchCommunity(CommunityDTO communityDTO) {
        System.out.println("serviceimpl");
        return communityDAO.searchCommunityByDTO(communityDTO);
    }

    @Override
    public Community findCommunitySelective(Community community) {
        return communityDAO.selectCommunitySelective(community);
    }

    @Override
    public List<OrderDTO> findOrderByLId(Integer currentPage, Integer pageSize,Integer lId) {
        return orderDAO.queryOrder(currentPage, pageSize, lId);
    }

    @Override
    public List<Community> findAllCommunityMap() {
        return communityDAO.selectAllCommunityMap();
    }

    @Override
    public List<OrderDTO> findAllOrder(Integer currentPage, Integer pageSize, OrderDTO orderDTO) {
        return orderDAO.queryOrderAndUser(currentPage,pageSize,orderDTO);
    }

    @Override
    @Cacheable(value = "comCount")
    public int findAllCount() {
        return communityDAO.selectAllCount();
    }

    @Override
    public void addCommunity(Community community) {
        communityDAO.insert(community);
    }

    @Override
    public Community findComByLid(Integer lid) {
        return communityDAO.slectByLid(lid);
    }


}
